package cn.chinaunicom.sdsi.gacx.commonSvc.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import cn.chinaunicom.sdsi.frm.sys.R;
import cn.chinaunicom.sdsi.frm.sys.entity.SysStaff;
import cn.chinaunicom.sdsi.gacx.common.HttpUtils;
import cn.chinaunicom.sdsi.gacx.commonSvc.service.ICommonSvcService;
import net.sf.json.JSONObject;

@Service
public class CommonSvcServiceImpl implements ICommonSvcService {
	private final String ip_addr = "http://10.161.21.12";

	/**
	 * 获取本单位待备案数量
	 */
	@Override
	public String doCommonSvcService(HashMap<String, Object> map) {
		String result = "";
		String url = "";
		String query = "";
		String reqPath = "";

		String method = map.get("method") == null ? "" : (String) map.get("method");
		if ("getTelNoByImsi".equals(method)) {// IMSI查询
			String imsi = map.get("imsi") == null ? "" : (String) map.get("imsi");
			query += "imsi=" + imsi + "&";

			reqPath = "/api_imsi/getTelNoByImsi";
		} else if ("getImsiByTelNo".equals(method)) {// 号码查询
			String telno = map.get("telno") == null ? "" : (String) map.get("telno");
			query += "telno=" + telno + "&";
			reqPath = "/api_telno/getImsiByTelNo";
		}

		String keyId = map.get("keyId") == null ? "" : (String) map.get("keyId");
		String token = map.get("token") == null ? "" : (String) map.get("token");
		String timestamp = map.get("timestamp") == null ? "" : (String) map.get("timestamp");

		url = ip_addr + reqPath;
		query += "keyId=" + keyId + "&token=" + token + "&timestamp=" + timestamp;

		System.out.println("pring url===============" + url);
		System.out.println("pring query===============" + query);
		try {
			result = HttpUtils.postCommon(url, query);
		} catch (Exception e) {
			System.out.println("pring Exception============" + e.toString());
		}
		System.out.println("pring result===============" + result);
		return result;
	}
}
